//
//  LDArtifactController.m
//  Gift
//
//  Created by 李迪 on 15/11/16.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "LDArtifactController.h"
#import "LDArtifactTabController.h"
#import "LDSecArtController.h"
#import "BaseHeader.h"
@interface LDArtifactController ()

@property (nonatomic, retain)UISegmentedControl *segmented;
@property (nonatomic, retain)LDArtifactTabController *tabController;
@property (nonatomic, retain)LDSecArtController *secArtController;



@end

@implementation LDArtifactController

-(void)dealloc{
    [self.segmented release];
    [self.tabBarController release];
    [self.secArtController release];
    [super dealloc];
}



- (void)caratesegmented{
    
    NSArray *array = @[@"神器",@"手工"];
    self.segmented = [[UISegmentedControl alloc]initWithItems:array];
    self.segmented.frame = CGRectMake(100, 10, 100, 30);
    self.navigationItem.titleView = self.segmented;
    self.segmented.selectedSegmentIndex = 0;
    [self.segmented addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    self.tabController = [[LDArtifactTabController alloc]init];
    self.tabController.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [self addChildViewController:self.tabController];
    [self.view addSubview:self.tabController.view];
    
    self.secArtController = [[LDSecArtController alloc]init];
    self.secArtController.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}

- (void)segmentAction:(UISegmentedControl *)Seg{
    NSInteger Index = Seg.selectedSegmentIndex;
    
    switch (Index) {
        case 0:
            
            [self addChildViewController:self.tabController];
            [self.view addSubview:self.tabController.view];
            self.secArtController.view.hidden = YES;
            self.tabController.view.hidden = NO;
            break;
        case 1:
            [self addChildViewController:self.secArtController];
            [self.view addSubview:self.secArtController.view];
            self.secArtController.view.hidden = NO;
            self.tabController.view.hidden = YES;
            break;
    }
}




- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = nil;
    self.navigationController.title = @"神器";
    [self caratesegmented];
    self.title = @"神器";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20.], NSForegroundColorAttributeName:[UIColor colorWithRed:1.000 green:1.00 blue:1.000 alpha:1.000]}];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
